Skip to content

Conversation

@DerTimonius
Copy link
Contributor

Summary

This PR fixes an issue with the useJsxKeyInIterable that did not match the original ESLint plugin: when a fragment does not have a key in a .map (or similar) call, it's children are marked as incorrect, not the whole fragment.

Looking more closely at the original rule I also noticed that checkShorthandFragment is an opt-in check.
Therefore I added the related option.

Closes #5490

Test Plan

Adapted the snapshots, removed invalid code that was found in valid.jsx (for example: even if all children of a fragment would have keys, the fragment is still marked as incorrect in the original rule), and added an additional snapshot with the option to check shorthand fragments.

@github-actions github-actions bot added A-Linter Area: linter L-JavaScript Language: JavaScript and super languages labels Apr 25, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 25, 2025

CodSpeed Performance Report

Merging #5773 will not alter performance

Comparing DerTimonius:fix/useIterableKey-fragment-bug (5b3a0a8) with main (e6c512a)

Summary

✅ 95 untouched benchmarks

"@biomejs/biome": patch
---

Updates the useJsxKeyInIterable rule to more closely match the behavior of the ESLint plugin (e.g. mark the whole fragment as incorrect when no key is present). This also adds the option to check shorthand fragments (`<></>`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Updates the useJsxKeyInIterable rule to more closely match the behavior of the ESLint plugin (e.g. mark the whole fragment as incorrect when no key is present). This also adds the option to check shorthand fragments (`<></>`)
Updates the [`useJsxKeyInIterable`](https://biomejs.dev/linter/rules/use-jsx-key-in-iterable/) rule to more closely match the behavior of the ESLint plugin (e.g. mark the whole fragment as incorrect when no key is present). This also adds the option to check shorthand fragments (`<></>`)

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@ematipico ematipico merged commit e6c512a into biomejs:main May 2, 2025
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Linter Area: linter L-JavaScript Language: JavaScript and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

💅 useJsxKeyInIterable does not recognize unnamed fragment

2 participants